package com.itheima.server.service;

import com.itheima.api.UserLocationApi;
import com.itheima.domain.UserLocation;
import com.itheima.server.exception.BusinessException;
import com.itheima.server.exception.ErrorResult;
import com.itheima.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class BaiduService {


    @DubboReference
    private UserLocationApi userLocationApi;

    /**
     * 上传地理位置
     * @param latitude
     * @param longitude
     * @param addrStr
     */
    public void location(double latitude, double longitude, String addrStr) {
        //更新地理位置
        boolean flag = userLocationApi.location(latitude,longitude,addrStr, UserHolder.getUserId());
        if (!flag){
            throw new BusinessException(ErrorResult.error());
        }
    }


}
